<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <script src="/property/js/jquery.min.js"></script>
    <th:block th:include="include :: header('新增岗位')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-product-add" enctype="multipart/form-data" >
        <!--			<div class="form-group">-->
        <!--				<label class="col-sm-3 control-label is-required">商品id：</label>-->
        <!--				<div class="col-sm-8">-->
        <!--					<input class="form-control" type="text" name="product_id" id="product_id" required>-->
        <!--				</div>-->
        <!--			</div>-->
        <!--        <input class="form-control" type="hidden" name="id" id="id" required>-->
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">商铺名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="name" id="name" required>
            </div>
            <label class="col-sm-3 control-label is-required">商铺地址：</label>
            <div class="col-sm-8">
                <select class="form-control" id="location_id" name="location_id">
                </select>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    $(document).ready(function(){
        $.ajax({
            url:  ctx + "/evaluation/location/locationList",
            type: "post",
            dataType: "json",
            success:function(data){
                console.log(data.value);
                for (var i = 0; i < data.locations.length; i++) {
                    //先创建好select里面的option元素
                    var option = document.createElement("option");
                    //给option的text赋值,这就是你点开下拉框能够看到的东西
                    $(option).text(data.locations[i].name);
                    $(option).val(data.locations[i].id);
                    $('#location_id').append(option);
                }
            },
            error:function (data) {
                console.log(data);
            }
        });
    });
</script>
<script type="text/javascript">
    var prefix = ctx + "evaluation";
    function submitHandler() {
        var name = $("#name").val();
        if (name=="" || name==null){
            $.modal.alertError("请输入商铺名");
            return;
        }
        var locationID = $("#location_id").val();
        console.log(locationID);
        if (locationID=="" || locationID==null){
            $.modal.alertError("请选择商铺地址");
            return;
        }
        $.operate.save(prefix + "/addStore1", $('#form-product-add').serialize());
    }
</script>
</body>
</html>
